<style>
    .layui-table-cell .layui-table-sort {
        display: none;
    }
</style>

<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 头部操作栏 -->
            <div class="layui-form lay-header">
                <div class="toolbar">
                    <div class="layui-form-item lay-query-content">
                        <div class="lay-query-box">
                            <div class="query-lt">
                                <div class="layui-inline">
                                    <label class="layui-form-label">物料编号：</label>
                                    <div class="layui-input-inline">
                                        <input name="skuCode" id="skuCode" class="layui-input"
                                               type="text"
                                               placeholder="请输入物料编号" autocomplete="off"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">客户名称：</label>
                                    <div class="layui-input-inline">
                                        <input name="customerName" id="customerName" class="layui-input"
                                               type="text"
                                               placeholder="请输入客户名称" autocomplete="off"/>
                                    </div>
                                </div>
                                <!-- 客户名称 -->
                                <div class="layui-inline">
                                    <label class="layui-form-label">采购组织：</label>
                                    <div class="layui-input-inline">
                                        <input name="purchaseCode" id="purchaseCode" class="layui-input"
                                               type="text"
                                               placeholder="请输入采购组织" autocomplete="off"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <button class="layui-btn icon-btn color-green" lay-filter="formSubSearchLog"
                                            lay-submit layui-form-keyDownSearch="true">查询
                                    </button>
                                    <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>
                                        重置
                                    </button>
                                </div>
                            </div>
                            <div class="query-rt">
                            </div>
                        </div>
                    </div>
                    <div class="lay-btn-rows">
                        <div class="lay-btn-box">
                        </div>
                    </div>
                </div>
            </div>
            <!-- 表格 -->
            <table class="layui-table" id="proDeliveryOrderTableInfo" lay-filter="proDeliveryOrderTableInfo"></table>
        </div>
    </div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="proQualityTableBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">详情</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="edit">修改</a>
</script>

<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'laydate', 'admin', 'laytpl', 'tableTreeDj', 'config'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var table = layui.table;
        var form = layui.form;
        var config = layui.config;
        var admin = layui.admin;

        // 渲染表格
        var insTb = table.render({
            elem: '#proDeliveryOrderTableInfo',
            url: config.base + 'production/delivery/admin/skuOrderCollect/list',
            page: true,
            cellMinWidth: 100,
            cols: [[
                {type: 'numbers', title: '序号', align: 'center'}
                , {field: 'skuCode', title: '物料编号', align: 'center', width: 140}
                , {field: 'skuName', title: '物料名称', align: 'center', width: 140}
                , {field: 'skuSpec', title: '规格码', align: 'center', width: 140}
                , {field: 'productionLine', title: '产线', align: 'center'}
                , {field: 'remark', title: '组件描述', align: 'center'}
                , {field: 'customerName', title: '所属客户', align: 'center', width: 140}
                , {field: 'purchaseCode', title: '采购组织', align: 'center'}
                , {field: 'unitName', title: '单位', align: 'center', width: 140}
                , {field: 'deliveryNums', title: '提货数', align: 'center'}
                , {field: 'alreadyNums', title: '下料数', align: 'center'}
                , {field: 'sendNums', title: '已发货数', align: 'center'}
                , {field: 'kuiQianNums', title: '欠料数', align: 'center'}
                , {align: 'center', toolbar: '#proQualityTableBar', title: '操作', width: 120}
            ]],
            done: function (res, curr, count) {
                //移除按钮
                var menuButton = config.getMenuButton(location.hash);
                console.log("menuButtton", menuButton);
                if (menuButton.indexOf("搜索") == -1) {
                    $('.layui-form.toolbar').remove();
                }
                if (menuButton.indexOf("修改") == -1) {
                    $("[lay-event='edit']").remove();
                }
                if (menuButton.indexOf("删除") == -1) {
                    $("[lay-event='del']").remove();
                }
            }
        });

        //渲染下拉
        form.render('select');

        // 工具条点击事件
        table.on('tool(proDeliveryOrderTableInfo)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') { //详情
                showDetailModel(data);
            }
        });

        // 搜索
        form.on('submit(formSubSearchLog)', function (data) {
            data.field.givenStartTimed = $("#givenStartTimed").val();
            insTb.reload({where: data.field, page: {curr: 1}}, 'data');
        });

        // 重置搜索
        form.on('submit(resets)', data => {
            $(".lay-header").find('select').val("");
            $(".lay-header").find('input').val("");
            let field = data.field;
            for (let key in field) {
                field[key] = ''
            }
            insTb.reload({where: field, page: {curr: 1}}, 'data');
        });

        function showDetailModel(data){
            admin.putTempData("productOrderCollectDetailData", data);
            admin.formOpen({
                type: 1,
                area: ['70%', '85%'],
                style: 'font-size: 20px;',
                title: "详情",
                path: "components/product/delivery/orderSkuCollectDetail.html",
                finish: function () {
                    // table.reload(insTb, {});
                    insTb.reload({where: data.field, page: {curr: 1}}, 'data');
                }
            });
        }
    });
</script>